using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using FikriKibar.Entities.Concrete;

namespace FikriKibar.DataAccess.Mapping
{
    public class SessionMapping : EntityTypeConfiguration<Session>
    {
        public SessionMapping()
            : this("dbo")
        {
        }
 
        public SessionMapping(string schema)
        {
            ToTable(schema + ".Session");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");

            HasRequired(a => a.User).WithMany(b => b.Sessions).HasForeignKey(c => c.CreatedBy);
        }
    }

}
